package o;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint.FontMetricsInt;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.text.Layout;
import android.text.Layout.Alignment;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.util.TypedValue;
import com.huawei.hwphy2d.physical.util.BarrierParameters;

public class dsa extends Drawable {
    private static final int[] ˎ = new int[]{16842901, 16842902, 16842903, 16842904};
    private static final int[] ॱ = new int[]{16842804};
    private CharSequence ʻ = "";
    private Path ʼ;
    private ColorStateList ʽ;
    private StaticLayout ˊ;
    private Resources ˋ;
    private TextPaint ˏ;
    private Rect ॱॱ;
    private Alignment ᐝ = Alignment.ALIGN_NORMAL;

    public dsa(Context context) {
        TypedArray obtainStyledAttributes;
        ColorStateList colorStateList;
        int i;
        Typeface typeface = null;
        this.ˋ = context.getResources();
        this.ॱॱ = new Rect();
        this.ˏ = new TextPaint(1);
        this.ˏ.density = this.ˋ.getDisplayMetrics().density;
        this.ˏ.setDither(true);
        int i2 = 15;
        TypedArray obtainStyledAttributes2 = context.getTheme().obtainStyledAttributes(ॱ);
        int resourceId = obtainStyledAttributes2.getResourceId(0, -1);
        obtainStyledAttributes2.recycle();
        if (resourceId != -1) {
            obtainStyledAttributes = context.obtainStyledAttributes(resourceId, ˎ);
        } else {
            obtainStyledAttributes = null;
        }
        if (obtainStyledAttributes != null) {
            resourceId = -1;
            ColorStateList colorStateList2 = null;
            int i3 = -1;
            for (int i4 = 0; i4 < obtainStyledAttributes.getIndexCount(); i4++) {
                int index = obtainStyledAttributes.getIndex(i4);
                switch (index) {
                    case 0:
                        i2 = obtainStyledAttributes2.getDimensionPixelSize(index, i2);
                        break;
                    case 1:
                        i3 = obtainStyledAttributes2.getInt(index, i3);
                        break;
                    case 2:
                        resourceId = obtainStyledAttributes2.getInt(index, resourceId);
                        break;
                    case 3:
                        colorStateList2 = obtainStyledAttributes2.getColorStateList(index);
                        break;
                    default:
                        break;
                }
            }
            obtainStyledAttributes.recycle();
            int i5 = i3;
            colorStateList = colorStateList2;
            i = resourceId;
            resourceId = i5;
        } else {
            resourceId = -1;
            i = -1;
            colorStateList = null;
        }
        if (colorStateList == null) {
            colorStateList = ColorStateList.valueOf(-1);
        }
        ˏ(colorStateList);
        ˎ((float) i2);
        switch (resourceId) {
            case 1:
                typeface = Typeface.SANS_SERIF;
                break;
            case 2:
                typeface = Typeface.SERIF;
                break;
            case 3:
                typeface = Typeface.MONOSPACE;
                break;
        }
        ˊ(typeface, i);
    }

    public void ˎ(CharSequence charSequence) {
        if (charSequence == null) {
            charSequence = "";
        }
        this.ʻ = charSequence;
        ॱ();
    }

    public void ˋ(int i, float f) {
        ˎ(TypedValue.applyDimension(i, f, this.ˋ.getDisplayMetrics()));
    }

    private void ˎ(float f) {
        if (Math.abs(f - this.ˏ.getTextSize()) > BarrierParameters.RESTITUTION) {
            this.ˏ.setTextSize(f);
            ॱ();
        }
    }

    public int ˎ() {
        FontMetricsInt fontMetricsInt = new FontMetricsInt();
        this.ˏ.getFontMetricsInt(fontMetricsInt);
        return Math.abs(fontMetricsInt.top - fontMetricsInt.ascent);
    }

    public void ˊ(Typeface typeface, int i) {
        boolean z = false;
        if (i > 0) {
            Typeface defaultFromStyle;
            int style;
            float f;
            if (typeface == null) {
                defaultFromStyle = Typeface.defaultFromStyle(i);
            } else {
                defaultFromStyle = Typeface.create(typeface, i);
            }
            ˊ(defaultFromStyle);
            if (defaultFromStyle != null) {
                style = defaultFromStyle.getStyle();
            } else {
                style = 0;
            }
            style = (style ^ -1) & i;
            TextPaint textPaint = this.ˏ;
            if ((style & 1) != 0) {
                z = true;
            }
            textPaint.setFakeBoldText(z);
            TextPaint textPaint2 = this.ˏ;
            if ((style & 2) != 0) {
                f = -0.25f;
            } else {
                f = 0.0f;
            }
            textPaint2.setTextSkewX(f);
            return;
        }
        this.ˏ.setFakeBoldText(false);
        this.ˏ.setTextSkewX(0.0f);
        ˊ(typeface);
    }

    public void ˊ(Typeface typeface) {
        if (this.ˏ.getTypeface() != typeface) {
            this.ˏ.setTypeface(typeface);
            ॱ();
        }
    }

    public void ˏ(int i) {
        ˏ(ColorStateList.valueOf(i));
    }

    public void ˏ(ColorStateList colorStateList) {
        this.ʽ = colorStateList;
        ˏ(getState());
    }

    private void ॱ() {
        if (this.ʼ != null) {
            this.ˊ = null;
            this.ॱॱ.setEmpty();
        } else {
            this.ˊ = new StaticLayout(this.ʻ, this.ˏ, (int) Math.ceil((double) Layout.getDesiredWidth(this.ʻ, this.ˏ)), this.ᐝ, 1.0f, 0.0f, false);
            this.ॱॱ.set(0, 0, this.ˊ.getWidth(), this.ˊ.getHeight());
        }
        invalidateSelf();
    }

    private boolean ˏ(int[] iArr) {
        int colorForState = this.ʽ.getColorForState(iArr, -16777216);
        if (this.ˏ.getColor() == colorForState) {
            return false;
        }
        this.ˏ.setColor(colorForState);
        return true;
    }

    protected void onBoundsChange(Rect rect) {
        this.ॱॱ.set(rect);
    }

    public boolean isStateful() {
        return this.ʽ.isStateful();
    }

    protected boolean onStateChange(int[] iArr) {
        return ˏ(iArr);
    }

    public int getIntrinsicHeight() {
        if (this.ॱॱ.isEmpty()) {
            return -1;
        }
        return this.ॱॱ.bottom - this.ॱॱ.top;
    }

    public int getIntrinsicWidth() {
        if (this.ॱॱ.isEmpty()) {
            return -1;
        }
        return this.ॱॱ.right - this.ॱॱ.left;
    }

    public void draw(Canvas canvas) {
        Rect bounds = getBounds();
        int save = canvas.save();
        canvas.translate((float) bounds.left, (float) bounds.top);
        if (this.ʼ == null) {
            this.ˊ.draw(canvas);
        } else {
            canvas.drawTextOnPath(this.ʻ.toString(), this.ʼ, 0.0f, 0.0f, this.ˏ);
        }
        canvas.restoreToCount(save);
    }

    public void setAlpha(int i) {
        if (this.ˏ.getAlpha() != i) {
            this.ˏ.setAlpha(i);
        }
    }

    public int getOpacity() {
        return this.ˏ.getAlpha();
    }

    public void setColorFilter(ColorFilter colorFilter) {
        if (this.ˏ.getColorFilter() != colorFilter) {
            this.ˏ.setColorFilter(colorFilter);
        }
    }
}
